const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let limit;
let initArr = [];
rl.on("line", (line)=>{
    if(limit === undefined) {
        limit = Number(line.trim())
    } else {
        initArr = line.trim().split(" ").map(Number)
        console.log(getResult(initArr, limit))
        // clear
        limit = undefined
        initArr.length = 0
    }

})

/**
 *
 * @param initArr {[number]} 源数据
 * @param limit {number} 限制
 * @return {number} 返回分组数
 */
function getResult(initArr, limit) {
    // 首先对礼物进行分组, 最好首尾 相拼, 如果大于, 就直接用尾巴
    initArr.sort((a, b) => a - b)
    let count = 0
    let left = 0
    let right = initArr.length - 1

    while(left <= right) {
        let sum = initArr[left] + initArr[right]
        if(sum> limit) {
            right--
            count++
        } else {
            left++
            right--
            count++
        }
    }
    return count
}